package com.study.controller;

import com.study.service.impl.EchartsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/echarts/*")
public class EchartsController extends BaseController{


    private final EchartsServiceImpl echartsService = new EchartsServiceImpl();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String method = req.getParameter("method");

        switch (method){
            case "display1":
                display1(req, resp);
                break;
            case "display2":
                display2(req, resp);
                break;
        }
    }

    private void display2(HttpServletRequest req, HttpServletResponse resp) {
        //List list1 = echartsService.selectAll();   //楼号与人数
        //List list2 = echartsService.selectAll2();  //楼号与人数
        //
        //toJSON(resp,);

    }

    private void display1(HttpServletRequest req, HttpServletResponse resp) {
        System.out.println("EchartsController.display1");
        List list = echartsService.selectAll();
        toJSON(resp, list);
    }
}
